<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/socket.js"></script>
    <script src="js/jquery.js"></script>
</head>
<body>
<input type="button" value="建立连接" onclick="con()"> <br>
内容: <input id="msg" type="text"><br>
<input type="button" value="发送数据" onclick="send()"> <br>
</body>

<script>
    var socket;
    function con() {
        if(!socket){ // !undefined
            socket = createScoket("token2") //随便发送一条数据123
        }
    }
    function send(){
        var msg = $("#msg").val();
        socket.send(msg);
    }
</script>
</html>
